﻿<template>
    <div id="app">

        <mt-header v-bind:title="title" style="background-color:#fda10e">
            <a slot="left" @click="back()">返回</a>

        </mt-header>
        <div class="mui-card">
            <ul class="mui-table-view">
                <li class="mui-table-view-cell" v-for="item in list">
                    <a class="mui-navigate">
                        {{item.truename}}&nbsp;&nbsp; {{item.signdate}} &nbsp;&nbsp;签到成功

                    </a>
                </li>

            </ul>

        </div>
        <ul v-infinite-scroll="loadMore"
            infinite-scroll-disabled="busy"
            infinite-scroll-distance="10" class="clearfix">
            <div class="loading">{{loading}}</div>
        </ul>
    </div>

</template>
<script>
    import { Toast } from 'mint-ui';
    import Bus from '../bus.js'
    export default {
        name: 'app',
        data() {
            return {
                title: "我的签到",
                page: 1,
                list: [],
                busy: true,
                loading: "加载中..."
            }
        },
        mounted() {
            window.history.pushState('forward', null, '#');
            window.history.forward(1);
            window.onpopstate = () => {
                Bus.$emit('val', "show");
                this.$router.go(-1);
            }
        },
        methods:
        {
           
            loadMore() {
                this.$data.busy = true  //将无限滚动给禁用
                setTimeout(() => {  //发送请求有时间间隔第一个滚动时间结束后才发送第二个请求
                    this.$data.page = this.$data.page + 1;
                    this.load();
                }, 500);
            },
            load: function () {
                var studentid = window.localStorage.getItem("studentid");

                var page = this.$data.page;
                var _this = this;
                this.$api.post('wx/Index/getstudentsignlist', {
                    "studentid": studentid, "page": page
                }, response => {
                    if (response.status >= 200 && response.status < 300) {
                        console.log(response.data);
                        var data = response.data;
                        if (data.status == 200) {

                            if (data.data.length > 0) {
                                for (var i = 0; i < data.data.length; i++) {

                                    _this.$data.list.push(data.data[i]);
                                }


                                _this.$data.busy = false;
                            } else {

                                _this.$data.busy = true;
                                _this.$data.loading = "没有数据了";
                            }



                        }


                        console.log(_this.$data.list);

                        //请求成功，response为成功信息参数
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });

            },

            back: function () {
                Bus.$emit('val', "show");
                this.$router.go(-1);
            }
        },
        components: {

        },
        created: function () {
            this.load();

        }
    }

  
</script>

<style scoped>
    .loading {
        width: 100%;
        margin-bottom: 2px;
        text-align: center;
    }

   
</style>